package com.xiyu.service.controller.admin.health;
import com.xiyu.service.vo.health.medicinePlan.MedicinePlanSingleGetOutput;
import com.xiyu.service.vo.health.medicinePlan.MedicinePlanUpdateInput;
import com.xiyu.service.vo.health.medicinePlan.MedicinePlanGetOutput;
import com.xiyu.service.vo.health.medicinePlan.MedicinePlanCreateInput;
import com.xiyu.service.vo.health.medicinePlan.MedicinePlanPageQueryOutput;
import com.xiyu.service.vo.health.medicinePlan.MedicinePlanPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.health.MedicinePlanService;

@Tag(name = "用药计划")
@RestController
@RequestMapping("/health/medicine-plan")
@Validated
public class MedicinePlanController {

    @Resource
    private MedicinePlanService medicinePlanService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询用药计划")
    @PreAuthorize("@ss.hasPermission('health:medicinePlan:query')")
    public CommonResult<PageResult<MedicinePlanPageQueryOutput>> pageQuery(@Valid MedicinePlanPageQueryInput inputVO) {
        return success(medicinePlanService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "创建用药计划")
    @PreAuthorize("@ss.hasPermission('health:medicinePlan:create')")
    public CommonResult<Long> create(@Valid @RequestBody MedicinePlanCreateInput inputVO) {
        return success(medicinePlanService.create(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个用药计划")
    @Parameter(name = "id", description = "用药计划主键ID", example = "")
    public CommonResult<MedicinePlanGetOutput> get(@RequestParam("id") Long id) {
        return success(medicinePlanService.get(id));
    }

    @PutMapping("/update")
    @Operation(summary = "更新用药计划")
    @PreAuthorize("@ss.hasPermission('health:medicinePlan:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody MedicinePlanUpdateInput inputVO) {
        return success(medicinePlanService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除用药计划")
    @PreAuthorize("@ss.hasPermission('health:medicinePlan:delete')")
    @Parameter(name = "id", description = "用药计划主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(medicinePlanService.deleted(id));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个用药计划")
    @Parameter(name = "id", description = "用药计划主键ID", example = "")
    public CommonResult<MedicinePlanSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(medicinePlanService.singleGet(id));
    }

}
